#------------------------------------------------------------------------------
#   File:       tex2text.py
#   Purpose:    
#   Author:     James Mynderse
#   Revised:
#   License:    GPLv3 see LICENSE.TXT    
#------------------------------------------------------------------------------

'''
'''

from optparse import OptionParser
from lib_tex2text import Tex

## Options
usage = "usage: %prog [options] -f FILE_NAME"
parser = OptionParser(usage=usage)
parser.add_option('-f','--file name', dest='filename', default='',
    help="main file name")
(options, args) = parser.parse_args()

if not options.filename:
    print "[Error] Missing -f FILE_NAME argument. Try '-h' for help."
    exit(1)

# Open the tex file
TexFileName = ('%s.tex') % (options.filename)
TexFile = open(TexFileName,'r+U')
# Create a destination file
NewFileName = ('%s.text') % (options.filename)
NewFile = open(NewFileName,'a')

TEX = Tex(TexFile,NewFile)
TEX.ParseFile()
TEX.CloseFiles()
# TEX.SpellCheck()


print ('DONE!')
